package com.yongbao.model.util;

import com.yongbao.model.dtomapper.AreaStreetDtoMapper;
import com.yongbao.model.domain.AreaStreetDO;
import com.yongbao.model.vo.AreaStreetTreeVO;
import com.yongbao.model.vo.AreaStreetVO;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhanghong
 */
public class AreaStreetConvert {

    public static List<AreaStreetVO> buildAreaStreetVoList(List<AreaStreetDO> areaStreetDOList) {
        if (CollectionUtils.isEmpty(areaStreetDOList)) {
            return Lists.newArrayList();
        }
        List<AreaStreetVO> areaStreetVOList = new ArrayList<>();
        for (AreaStreetDO areaStreetDO : areaStreetDOList) {
            areaStreetVOList.add(AreaStreetDtoMapper.INSTANCE.do2VO(areaStreetDO));
        }

        return areaStreetVOList;
    }

    /**
     * DO转TreeVO
     *
     * @param doList
     * @return
     */
    public static List<AreaStreetTreeVO> buildAreaStreetTreeVoList(List<AreaStreetDO> doList) {
        if (CollectionUtils.isEmpty(doList)) {
            return Lists.newArrayList();
        }
        List<AreaStreetTreeVO> treeVoList = new ArrayList<>();
        for (AreaStreetDO item : doList) {
            treeVoList.add(AreaStreetDtoMapper.INSTANCE.do2TreeVO(item));
        }

        return treeVoList;
    }
}
